#ifndef C3POM_APPLICATION_H
#define C3POM_APPLICATION_H
#include<map>
#include<string>
#include<vector>
#include<omp.h>
#include"command.h"
#include"service.h" 

namespace c3pom{
	class Application
	{
		private:
			omp_lock_t envarLock;
			omp_lock_t cmdLock;
			omp_lock_t serLock;
			std::map<std::string,std::string> envar;
			std::map<std::string,Service*> services;
			std::map<std::string,Command*> commands;

			//基本服务，开放全部访问权限
			friend class PortalBufManager;
			friend class PluginManager;
			friend class Log;
			//基本命令，开放全部访问权限
			friend class Env;
			friend class Help;
			friend class Svcm;
			class Env:public Command
			{
			public:
				int exec(std::vector<std::string>);
				std::string desc();
				std::string name();
			};
			class Help:public Command
			{ 
			public:
				int exec(std::vector<std::string>);
				std::string desc();
				std::string name();
			};
			class Svcm:public Command
			{
				public:
					int exec(std::vector<std::string>);
					std::string desc();
					std::string name();
			};
		public:
			static Application* getInstance();//单例模式下使用
			Application();
			void init();
			void run();
			void regCommand(Command*);//注册新命令
			void regService(Service*);//注册新的基础服务
		protected:
			void shell();
	};
}
#endif
